package com.glsc.ngateway.common.base.enums;

import com.glsc.ngateway.common.api.common.enums.RabbitExcQueConstant;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import java.util.Arrays;

@AllArgsConstructor
@NoArgsConstructor
@Getter
public enum RabbitExcEnum {

    AM_DATA("AMdataExc", "gateway.exchange.fwFlow.amdata"),
    AM_DATA_PRE("AMdataPreExc", "gateway.exchange.pre.amdata"),

    AM_PRODUCT("AMproductExc", "gateway.exchange.fwFlow.amproduct"),
    AM_PRODUCT_PRE("AMproductPreExc", "gateway.exchange.pre.amproduct"),

    GATEWAY_PLATFORM("GatewayPlatformExc", "gateway.exchange.fwFlow.platform"),
    GATEWAY_PLATFORM_PRE("GatewayPlatformPreExc", "gateway.exchange.pre.platform"),

    GATEWAY_OPMANAGE("GatewayOpmanageExc", "gateway.exchange.fwFlow.opmanage"),
    GATEWAY_OPMANAGE_PRE("GatewayOpmanagePreExc", "gateway.exchange.pre.opmanage"),

    GATEWAY_OAFLOW("GatewayOaflowExc", "gateway.exchange.fwFlow.oaflow"),
    GATEWAY_OAFLOW_PRE("GatewayOaflowPreExc", "gateway.exchange.pre.oaflow"),

    GATEWAY_ITFLOW("GatewayItflowExc", "gateway.exchange.fwFlow.itflow"),
    GATEWAY_ITFLOW_PRE("GatewayItflowPreExc", "gateway.exchange.pre.itflow"),

    GATEWAY_PLATFORM_SYNC_FLOW("GatewayPlatformSyncFlowExc", "gateway.exchange.fwFlow.oamobileaudit"),
    GATEWAY_PLATFORM_SYNC_FLOW_PRE("GatewayPlatformSyncFlowPreExc", "gateway.exchange.pre.oamobileaudit"),

    FIXED_INCOME("FixedIncomeExc", "gateway.exchange.fwFlow.fixedincome"),
    FIXED_INCOME_PRE("FixedIncomePreExc", "gateway.exchange.pre.fixedincome"),

    RPA("RPAExc", "gateway.exchange.fwFlow.rpa"),
    RPA_PRE("RPAPreExc", "gateway.exchange.pre.rpa"),

    DEMAND("DemandExc", "gateway.exchange.fwFlow.demand"),
    DEMAND_PRE("DemandPreExc", "gateway.exchange.pre.demand"),

    OA_FLOW_WATCH("OaFlowWatchExc", RabbitExcQueConstant.GATEWAY_EXCHANGE_FLOW_OA_FLOW_WATCH, true),
    OA_FLOW_WATCH_PRE("OaFlowWatchPreExc", RabbitExcQueConstant.GATEWAY_EXCHANGE_FLOW_OA_FLOW_WATCH_PRE, true),
    ;

    private String beanName;
    private String exchange;
    private boolean fanoutExchange;

    RabbitExcEnum(String beanName, String exchange) {
        this.beanName = beanName;
        this.exchange = exchange;
    }

    public static RabbitExcEnum seekByBeanName(@NotBlank String beanName) throws Exception {
        return Arrays.stream(RabbitExcEnum.values()).filter(r -> r.getBeanName().equals(beanName)).findAny().orElseThrow(() -> new Exception("未找到BeanName:" + beanName));
    }
}
